const express = require("express");

const app = express();

app.use(express.static("./public"));
app.use(express.json()); //解析 json

// API
// 中间件路由
// xhr.open('POST','http://127.0.0.1:3000/a/100?a=1&b=2')
// xhr.send(`{"a":1,"b":2}`)

app.post("/a/:id", (req, res) => {
  res.send({
    query: req.query,
    params: req.params,
    body: req.body,
  });
});

app.listen(3000, () => {
  console.log("success", "http://127.0.0.1:3000");
});
